﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_sitemap_breadcrumbs : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        createSiteMap();
    }

    private void createSiteMap()
    {
        string strSiteMap = "";
        //
        string strKieuPhong = clsCommon.fncGetRoute(this.Page, "userControl");
        if (!string.IsNullOrEmpty(strKieuPhong))
        {
            string strKieuPhong_VN = "";
            if (strKieuPhong == basConst.KP_TAT_CA) strKieuPhong_VN = "Cho thuê phòng trọ, nhà trọ";
            else strKieuPhong_VN = OsPortal.oStringHelper.fncCnvNullToString(clsKieuPhongTro.fncGetChiTiet_by_TenKhongDau(strKieuPhong).Rows[0]["KP_TEN"]);

            string strURL = "/" + strKieuPhong + "/toan-quoc";
            strSiteMap += "<span typeof='v:Breadcrumb'>";
            strSiteMap += " > <a href='" + strURL + "' property='v:title' rel='v:url'>" + strKieuPhong_VN + "</a>";
            strSiteMap += "</span>";
        }
        //
        string strKhuVuc = clsCommon.fncGetRoute(this.Page, "param1");
        if (!string.IsNullOrEmpty(strKhuVuc))
        {
            if (strKhuVuc == "toan-quoc")
            {
                string strURL = "/" + strKieuPhong + "/" + strKhuVuc + "";
                strSiteMap += "<span typeof='v:Breadcrumb'>";
                strSiteMap += " > <a href='" + strURL + "' property='v:title' rel='v:url'>Toàn quốc</a>";
                strSiteMap += "</span>";
            }
            else
            {
                if (clsKhuVuc.fncCheckParentKhuVuc(strKhuVuc))
                {
                    string strTinhThanh_Vi = clsKhuVuc.fncGetValue_DetailKV_By_TenKD(strKhuVuc, "KV_TEN");
                    string strURL = "/" + strKieuPhong + "/" + strKhuVuc + "";
                    strSiteMap += "<span typeof='v:Breadcrumb'>";
                    strSiteMap += " > <a href='" + strURL + "' property='v:title' rel='v:url'>Tại " + strTinhThanh_Vi + "</a>";
                    strSiteMap += "</span>";
                }
                else
                {
                    //Tỉnh thành
                    string strParentID = clsKhuVuc.fncGetValue_DetailKV_By_TenKD(strKhuVuc, "KV_PARENTID");
                    string strTinhThanh_Vi = clsKhuVuc.fncGetValue_DetailKV_By_ID(strParentID, "KV_TEN");
                    string strTinhThanh_En = clsKhuVuc.fncGetValue_DetailKV_By_ID(strParentID, "KV_TENKHONGDAU");
                    string strURL1 = "/" + strKieuPhong + "/" + strTinhThanh_En + "";
                    strSiteMap += "<span typeof='v:Breadcrumb'>";
                    strSiteMap += " > <a href='" + strURL1 + "' property='v:title' rel='v:url'>Tại " + strTinhThanh_Vi + "</a>";
                    strSiteMap += "</span>";
                    //Quận huyện
                    string strQuanHuyen_Vi = clsKhuVuc.fncGetValue_DetailKV_By_TenKD(strKhuVuc, "KV_TEN");
                    string strURL2 = "/" + strKieuPhong + "/" + strKhuVuc + "";
                    strSiteMap += "<span typeof='v:Breadcrumb'>";
                    strSiteMap += " > <a href='" + strURL2 + "' property='v:title' rel='v:url'>" + strQuanHuyen_Vi + "</a>";
                    strSiteMap += "</span>";
                }
            }

        }
        ltrSiteMap.Text = strSiteMap;
    }
}